<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{bundle.bvaccnt}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
        <h:form >

           <script type="text/javascript">  
                function handleSaveRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgBvaccnt.hide();  
                    }  
                }
                
                function handleDeleteRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgDelBVaccnt.hide();  
                    }  
                }
                
            </script>  

            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton value="#{bundle.btnNew}"
                                     icon="ui-icon-document"
                                     action="#{bvaccntBean.newData()}"  
                                     oncomplete="dlgBvaccnt.show()"
                                     update=":#{utilityBean.findClientId('displayBvaccnt')}"> 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgBvaccnt.show()"
                                     actionListener="#{bvaccntBean.openData()}"
                                     icon="ui-icon-disk" 
                                     update=":#{utilityBean.findClientId('displayBvaccnt')}" > 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnDelete}" icon="ui-icon-trash" onclick="dlgDelBVaccnt.show()" /> 

                    <p:commandButton type="push" value="#{bundle.btnPrint}" icon="ui-icon-print"/>
                </p:toolbarGroup>
            </p:toolbar>
            <br />
           
            <p:dataTable var="bvaccnt" value="#{bvaccntBean.bvaccnts}" id="dtBvaccnts"
                         selection="#{bvaccntBean.selectedData}" selectionMode="single" resizableColumns="true"
                         rowIndexVar="noUrut" rowKey="#{bvaccnt.bvaccntId}" 
                         paginator="true" rows="10" paginatorPosition="bottom" 
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="10,15,30">
                 <p:column style="width: 15px">
                    <f:facet name="header">No.</f:facet>
                    <h:outputText value="#{noUrut+1}" />
                 </p:column>
                <p:column style="width:200px" sortBy="#{bvaccnt.accountName}">
                    <f:facet name="header">#{bundle.bvaccnt}</f:facet>
                    <h:outputText value="#{bvaccnt.accountName}" />
                </p:column>
                <p:column style="width:200px;">
                    <f:facet name="header">#{bundle.glaccnt}</f:facet>
                    <h:outputText value="#{bvaccnt.glaccount.accountName}" />
                </p:column>
            </p:dataTable>
          
            <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                             header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelBVaccnt"> 
                <h:panelGrid cellspacing="0" cellpadding="0" styleClass="pComBtnD">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnYes}" update="dtBvaccnts" process="@this"
                                        oncomplete="handleDeleteRequest(xhr, status, args)"  
                                        actionListener="#{bvaccntBean.delete()}" />  
                        <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelBVaccnt.hide()" type="button" /> 
                    </f:facet>
                </h:panelGrid>  
            </p:confirmDialog> 
        </h:form>
            <p:dialog header="#{bundle.bvaccnt}" widgetVar="dlgBvaccnt" closable="true" dynamic="true" modal="true" appendToBody="true">
                <p:ajax event="close" listener="#{bvaccntBean.handleClose}"/>
                <h:form>
                <h:panelGrid id="displayBvaccnt" columns="3" styleClass="addELIT">
                    <h:outputLabel value= "#{bundle.bvaccnt}" /><h:outputLabel value= ":" />
                    <p:inputText rendered="#{bvaccntBean.insertedData!=null}" value="#{bvaccntBean.insertedData.accountName}" 
                                 required="true" label="#{bundle.accountName}" style="width: 150px;" />  
                                           
                    <p:outputLabel value= "#{bundle.glaccnt}" for="bvakunGlaccount" /><h:outputLabel value= ":" />
                    <p:selectOneMenu  value="#{bvaccntBean.insertedData.glaccount}" rendered="#{bvaccntBean.insertedData!=null}" 
                            style="width: 300px;" var="glacc1" converter="glaccnt" id="bvakunGlaccount" required="true">
                        <f:selectItem rendered="#{bvaccntBean.insertedData.glaccount!=null}" itemLabel="#{bvaccntBean.insertedData.glaccount.accountName}" itemValue="#{bvaccntBean.insertedData.glaccount}" />
                        <f:selectItems value="#{bvaccntBean.avaibleGL}" var="gl" itemLabel="#{gl.accountName}" itemValue="#{gl}" />
                        <p:column>#{glacc1.accountNo}</p:column>
                        <p:column>#{glacc1.accountName}</p:column>
                    </p:selectOneMenu>
                </h:panelGrid>
                    
                <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{bvaccntBean.save()}"
                                         update=":#{utilityBean.findClientId('dtBvaccnts')}"
                                         oncomplete="handleSaveRequest(xhr, status, args)"/>
                        <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgBvaccnt.hide()" icon="ui-icon-document"/>
                    </f:facet>
                </h:panelGrid>
                    </h:form>
            </p:dialog> 
        
        </ui:composition>    
    </h:body>
</html>
